package com.zlfund.cat.zjgsmk.ui.base;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zhy.autolayout.AutoLayoutActivity;
import com.zlfund.cat.zjgsmk.R;
import com.zlfund.cat.zjgsmk.constant.Constants;
import com.zlfund.cat.zjgsmk.util.StatusBarUtils;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by chenj
 * Created on 2017/8/15
 */

public abstract class BaseActivity extends AutoLayoutActivity {

    private LinearLayout mLlNavigation;
    private FrameLayout mFmBack;
    protected TextView mTvTitle;
    protected Context mContext;
    private Unbinder mBind;
    protected Intent mIntent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mIntent = getIntent();
        mContext = this;
        setContentView();
        mBind = ButterKnife.bind(this);
        initNavigationBar();
        transparentStatusBar();
        initData();
        setListener();
    }

    private void transparentStatusBar() {
        StatusBarUtils.transparentStatusBar(this);
    }

    @Override
    protected void onDestroy() {
        mBind.unbind();
        super.onDestroy();
    }

    protected void setPageTitle(CharSequence c){
        if (mTvTitle != null) {
            mTvTitle.setText(c);
        }
    }

    protected void initNavigationBar(){
        View v = findViewById(R.id.navigation_bar);
        mFmBack = (FrameLayout) findViewById(R.id.fm_left);
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        if (v != null) {
            mLlNavigation = (LinearLayout) v;
            mFmBack.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
        }
    }

    protected void setNavigationBackground(int color){
        mLlNavigation.setBackgroundColor(color);
    }

    protected abstract void setContentView();
    protected abstract void setListener();
    protected abstract void initData();
}
